package com.peng.servier;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.peng.mapper.UserMapper;
import com.peng.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImp implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public PageInfo<User> selectAll(String username, Integer status, Integer level,
                                    Integer page, Integer size) {
        PageHelper.startPage(page, size);
        return new PageInfo<User>(userMapper.selectAll(username, status, level));
    }

    @Override
    public boolean deleteUserById(Integer... id) {
        if (id != null) {
            for (Integer integer : id) {
                userMapper.deleteUserById(integer);
            }
        }
        return true;
    }

    @Override
    public boolean updateUserByStatus(int status, Integer... id) {
        if (id != null) {
            for (Integer integer : id) {
                userMapper.updateUserByStatus(integer, status);
            }
        }

        return true;
    }
}
